package com.voyage.generator.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.voyage.generator.entity.CodeConfig;
import com.voyage.generator.model.ColumnInfo;
import com.voyage.generator.model.TableInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
 *@Author: kangb on 2021/10/8 21:28
 *@param:
 *@return:
 *@Description:
 */
@Repository
public interface GenConfigRepository extends BaseMapper<CodeConfig> {


    @Select("select table_name ,create_time , engine, table_collation, table_comment as remark from information_schema.tables where table_schema = (select database()) order by create_time desc")
    List<TableInfo> getAllTableInfo();

    @Select("select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position")
    List<ColumnInfo> getColumnsByTableName(@Param("tableName") String tableName);
}
